<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <!-- 搜索 -->
      <el-input
        v-model="queryForm.tableName"
        clearable
        size="small"
        placeholder="请输入库名"
        style="width:200px"
        class="filter-item"
      />
      <el-input
        v-model="queryForm.fileName"
        clearable
        size="small"
        placeholder="请输入表名"
        style="width:200px"
        class="filter-item"
      />
      <rrOperation :crud="crud" />
      <div style="display: inline-block">
        <el-button
          class="filter-item"
          icon="el-icon-plus"
          type="primary"
          @click="crud.toAdd"
        >新增</el-button>
        <el-button
          class="filter-item"
          icon="el-icon-delete"
          type="danger"
          @click="crud.toDelete(crud.selections)"
        >删除</el-button>
      </div>
    </div>
    <!--表格渲染-->
    <el-table
      ref="table"
      v-loading="crud.loading"
      :data="tableList"
      border
      @select="crud.selectChange"
      @select-all="crud.selectAllChange"
      @selection-change="crud.selectionChangeHandler"
    >
      <el-table-column
        type="selection"
        width="40"
      />
      <el-table-column
        label="库名"
        prop="dbName"
      />
      <el-table-column
        label="表名"
        prop="tableName"
      />
    </el-table>
    <div style=" float: right;">
      <!--分页组件-->
      <pagination />
    </div>

    <el-dialog
      :close-on-click-modal="false"
      :before-close="crud.cancelCU"
      :visible.sync="crud.status.add > 0"
      title="新增灾备过滤表"
      width="500px"
      append-to-body
    >
      <el-form
        ref="form"
        :model="form"
        :rules="rules"
        :inline="true"
        label-width="100px"
      >
        <el-form-item
          label="库名"
          prop="dbName"
        >
          <el-select
            v-model="form.dbName"
            placeholder="请选择库名"
          >
            <el-option
              label="是"
              value="1"
            />
            <el-option
              label="否"
              value="2"
            />
          </el-select>
        </el-form-item>
        <el-form-item
          label="表名"
          prop="tableNameList"
        >
          <el-select
            v-model="form.tableNameList"
            placeholder="请选择表名"
          >
            <el-option
              label="是"
              value="1"
            />
            <el-option
              label="否"
              value="2"
            />
          </el-select>
        </el-form-item>
        <div
          class="dialog-footer"
          style="width:100%;text-align: center"
        >
          <el-button @click="crud.cancelCU">关 闭</el-button>
          <el-button
            type="primary"
            @click="crud.submitCU"
          >保 存</el-button>
        </div>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import pagination from '@crud/Pagination'
// crud交由presenter持有
const defaultCrud = CRUD({ title: '', url: '', crudMethod: {} })
const defaultForm = {
  id: null,
  dbName: null,
  tableNameList: []
}
export default {
  name: 'DisasterRecoveryBlacklist',
  components: { rrOperation, pagination },
  mixins: [presenter(defaultCrud), header(), form(defaultForm), crud()],
  data() {
    return {
      queryForm: {
        name: '',
        code: ''
      },
      rules: {
        dbName: [
          { required: true, message: '清选择库名', trigger: 'blur' }
        ],
        tableNameList: [
          { required: true, message: '请选择表名', trigger: 'blur' }
        ]
      },
      tableList: [
        {
          dbName: 'sdata',
          tableName: 'customer_info'
        }
      ]
    }
  },
  created() {
  },
  methods: {
    downFile(data) {

    }
  }
}
</script>
<style scoped>
</style>
